package com.kitty.game.gm.handler;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.equip.message.RespNotifyMiscEx;
import com.kitty.game.gm.GmService;
import com.kitty.game.role.model.Account;
import com.kitty.game.role.model.AccountLogin;
import com.kitty.game.role.model.Role;
import com.kitty.game.role.service.RoleService;
import com.kitty.mina.message.MessagePusher;

public class GmRoleInfoByRoleid implements GMFather {

    @Override
    public boolean handle(Role aaaaa, String content) {
        int roleId = Integer.parseInt(content);
        RoleService roleService = SpringUtils.getRoleService();
        GmService gmService = SpringUtils.getBean(GmService.class);
        Role role = roleService.getPlayerBy(roleId);
        if (role == null) {
            long uid = SpringUtils.getPlayerService().getUidBy(roleId);
            role = SpringUtils.getRoleService().getPlayerBy(uid);
            if (role == null) {
                MessagePusher.pushMessage(aaaaa, new RespNotifyMiscEx("角色不存在"));
                return true;
            }
        }
        Account account = SpringUtils.getAccountService().getAccount(role.getSid());
        if (account == null) {
            MessagePusher.pushMessage(aaaaa, new RespNotifyMiscEx("没有账号"));
            return true;
        }
        AccountLogin accountLogin = SpringUtils.getAccountService().queryAccount(role.getSid());
        if (accountLogin == null) {
            MessagePusher.pushMessage(aaaaa, new RespNotifyMiscEx("没有账号"));
            return true;
        }
        MessagePusher.pushMessage(aaaaa, new RespNotifyMiscEx(gmService.getRoleInfo(role,account,accountLogin)));
        return true;
    }
}
